package com_djm_2025_05_26.OOP.Static;

import java.util.Objects;

public class Student implements Cloneable{

    //姓名
    private String name;

    //年龄
    private int age;

    //当前学生的数量
    public static int count = 0;

    //班级
    private String className;

    //平均成绩
    private double averageGrade;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public  int getCount() {
        return count;
    }

    public  void setCount(int count) {
        Student.count = count;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public double getAverageGrade() {
        return averageGrade;
    }

    public void setAverageGrade(double averageGrade) {
        this.averageGrade = averageGrade;
    }

    public Student() {
        count++;
    }

    public Student(String name, int age, String className, double averageGrade) {
        this.name = name;
        this.age = age;
        this.className = className;
        this.averageGrade = averageGrade;
        count++;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return age == student.age && Double.compare(student.averageGrade, averageGrade) == 0 && name.equals(student.name) && Objects.equals(className, student.className);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, className, averageGrade);
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", className='" + className + '\'' +
                ", averageGrade=" + averageGrade +
                '}';
    }


    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    public  void func(){
        System.out.println("count = " + count);
    }
}
